{include file="Public:header" /}
<style>
    .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
        padding: 0px 5px;
        text-align: center;
        vertical-align: middle !important;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>评论列表</h5>
                    <div class="ibox-tools" style="margin-top: -6px;">
                        <a href="__MODULE__/{$Think.CONTROLLER_NAME}/{$Think.ACTION_NAME}" class="btn btn-primary"><i
                                class="fa fa-refresh"></i> 刷新</a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-3">
                            <a href="__URL__/addActivity?act=add" class="btn btn-primary">
                                <span class="fa fa-plus"></span>
                                添加评论
                            </a>
                        </div>
                        <form class="form-inline" action="__URL__/activityList" method="get" id="search-form2">
                            <div class="col-sm-9">
                                <div class="input-group col-sm-3  pull-right">
                                    <input type="text" name="user_name" placeholder="用户名称"
                                           class="input-sm form-control">
                                    <span class="input-group-btn">
			                                      <button type="button" onclick="ajax_get_table('search-form2',1)"
                                                          class="btn btn-sm btn-primary"> 搜索</button>
			                                    </span>
                                </div>

                                <div class="input-group col-sm-2 pull-right select_width">
                                    <select name="status" class="input-sm form-control select_no_border">
                                        <option value="">显示状态</option>
                                        <option value="1">是</option>
                                        <option value="2">否</option>
                                    </select>
                                </div>

                            </div>
                        </form>
                    </div>

                    <br/>
                    <div id="ajax_return">
                        <div class="table-responsive">
                            <form action="__URL__/operate" method="post" id="operate_form">
                                <table class="table table-bordered table-hover"
                                       id="categoryTable">
                                    <thead>
                                    <tr class="active">
                                        <th><input onclick="choosebox(this)" type="checkbox"/></th>
                                        <th height="40">编号</th>
                                        <th>用户名</th>
                                        <th>类型</th>
                                        <th>评论对象</th>
                                        <th>ip地址</th>
                                        <th width="10%">评论时间</th>
                                        <th>是否显示</th>
                                        <th width="100">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {foreach name="comment" item="comment"}
                                    <tr>
                                        <td><input type="checkbox" name="comment_id[]" value="{$comment['id']}"/></td>
                                        <td>{$comment['id']}</td>
                                        <td>{$comment['user_name']}</td>
                                        <td>
                                            {switch name="comment['comment_type']"}
                                            {case value="1"}活动{/case}
                                            {case value="2"}预约{/case}
                                            {/switch}
                                        </td>
                                        <td>{$comment['id_value']}</td>
                                        <td>{$comment['ip_address']}</td>
                                        <td>{$comment['add_time']|date="Y-m-d H:i:s",###}</td>
                                        <td>
                                            {switch name="comment['status']"}
                                            {case value="1"}是{/case}
                                            {case value="0"}否{/case}
                                            {/switch}
                                        </td>

                                        <td class="center">
                                            <!-- <button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top" title="标为垃圾邮件"><i class="fa fa-trash-o"></i>
                                                </button> -->
                                            <div class="dropdown">
                                                <button class="btn btn-primary dropdown-toggle"
                                                        type="button" id="dropdownMenu1" data-toggle="dropdown"
                                                        aria-haspopup="true" aria-expanded="true">
                                                    操作
                                                    <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu" style="min-width: 90px;"
                                                    aria-labelledby="dropdownMenu1">
                                                    <li>
                                                        {if condition="$comment['comment_type'] eq 1"}
                                                        <a role="button" class="btn btn-primary"
                                                           style="margin-bottom: 0px;"
                                                           href="__URL__/detail?id={$comment['id']}">
                                                            <span class="fa fa-edit"></span>
                                                            查看
                                                        </a>
                                                        {else/}
                                                        <a class="btn btn-primary" style="margin-bottom: 0px;" href="__URL__/make_detail?id={$comment['id']}">
                                                            <span class="fa fa-edit"></span>
                                                            查看
                                                        </a>
                                                        {/if}
                                                    </li>
                                                    <li>
                                                        <a role="button" class="btn btn-danger"
                                                           style="margin-bottom: 0px;"
                                                           onclick="deleteComment(this,{$comment['id']})"
                                                           href="javascript:void(0);">
                                                            <span class="fa fa-trash-o"></span>
                                                            删除
                                                        </a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </td>
                                    </tr>
                                    {/foreach}
                                    </tbody>
                                    <!-- <tfoot>
                                   <tr>
                                          <td colspan="3" class="footable-visible">
                                          <select name="type" class="input-sm form-control pull-left" style="width:100px;margin-right: 5px;">
                                                            <option value="">活动类型</option>
                                                           <option value="show">显示</option>
                                                           <option value="hide">隐藏</option>
                                                           <option value="del">删除</option>
                                        </select>
                                        <button tpye="submit" class="btn btn-primary pull-left"> 确认</button>
                                       </td>
                                       <td colspan="6" class="footable-visible">
                                        <ul class="pagination  pull-right">
                                       {$page}
                                     </ul>
                                       </td>
                                   </tr>
                                   </tfoot>  -->
                                </table>

                                <div class="col-sm-12" style="padding:0px;">
                                    <div class="col-sm-4" style="padding-left:0px;">
                                        <select id="operate" name="operate" class="input-sm form-control pull-left"
                                                style="width:100px;margin-right: 5px;">
                                            <option value="0">选择操作</option>
                                            <option value="show">显示</option>
                                            <option value="hide">隐藏</option>
                                            <option value="del">删除</option>
                                        </select>
                                        <button tpye="button" class="btn btn-primary pull-left"> 确认</button>
                                    </div>
                                    <div class="col-sm-8" style="padding:0px;">
                                        <ul class="pagination  pull-right">
                                            {$page}
                                        </ul>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    /* var h=1;
     function all_check(){
     if(h==1){
     $("input[name='rule_id[]']").each(function() {
     $(this).prop("checked", true);
     });
     h=2;
     }else if(h==2){
     $("input[name='rule_id[]']").each(function() {
     $(this).prop("checked", false);
     });
     h=1;
     }
     } */

    function choosebox(o) {
        var vt = $(o).is(':checked');
        if (vt) {
            $('input[type=checkbox]').prop('checked', vt);
        } else {
            $('input[type=checkbox]').removeAttr('checked');
        }
    }
</script>


<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">添加商品</h4>
            </div>
            <div class="modal-body">
                <!-- class都是bootstrap定义好的样式，验证是根据input中的name值 -->
                <form action="__URL__/addShop" method="post" id="defaultForm">

                    <div class="form-group">
                        <label for="categoryName">商品名称</label>
                        <input type="text" name="shop_name" style="border-radius: 4px;"
                               id="categoryName" class="form-control"/>
                    </div>

                    <div class="form-group">
                        <label for="categoryTitle">商品地址</label>
                        <input type="text" name="shop_address" style="border-radius: 4px;"
                               id="categoryTitle" class="form-control"/>
                    </div>

                    <div class="form-group">
                        <label for="categoryKeywords">商品电话</label>
                        <input type="text" name="shop_tel" style="border-radius: 4px;"
                               id="categoryKeywords" class="form-control"/>
                    </div>

                    <div class="form-group">
                        <label for="categoryDescription">商品描述</label>
                        <textarea name="shop_description" style="border-radius: 4px;"
                                  class="form-control" id="categoryDescription"/></textarea>
                    </div>

                    <div class="form-group">
                        <label for="shopTel">地铁地址</label>
                        <input type="text" name="metro_address" style="border-radius: 4px;"
                               id="shopTel" class="form-control"/>
                    </div>

                    <div class="form-group">
                        <label for="shopTel">商品坐标</label>
                        <input type="text" name="shop_coord" style="border-radius: 4px;"
                               id="shopTel" class="form-control"/>
                    </div>

                    <div class="modal-footer" id="parent_id">
                        <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
                        <button type="submit" class="btn btn-primary">提交</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<!-- 加载动画 -->
<!-- <div  class="spiner-example">
<div class="sk-spinner sk-spinner-wave">
<div class="sk-rect1"></div>
<div class="sk-rect2"></div>
<div class="sk-rect3"></div>
<div class="sk-rect4"></div>
<div class="sk-rect5"></div>
</div>
</div> -->
<!-- Modal -->

{include file="Public:footer" /}

<script>
    $(document).ready(function () {
        ajax_get_table('search-form2', 1);
    });


    //ajax 抓取页面
    function ajax_get_table(tab, page) {
        cur_page = page; //当前页面 保存为全局变量
        $.ajax({
            type: "POST",
            url: "__URL__/ajaxindex/p/" + page,//+tab,
            data: $('#' + tab).serialize(),// 你的formid
            success: function (data) {
                $("#ajax_return").html('');
                $("#ajax_return").append(data);
            }
        });
    }

    // window.onload=setTotal();

    //删除
    function deleteComment(obj, id) {
        layer.confirm('确定要删除数据吗', {btn: ['确认', '取消'], icon: 3, closeBtn: 2}, function (index) {
            $.ajax({
                url: '__URL__/deleteComment',
                data: {'id': id},
                type: 'get',
                dataType: 'json',
                async: false,   //取消同步，执行完之后再往下执行
                success: function (data) {
                    if (data.status == 1) {
                        layer.msg('' + data.message + '', {icon: 2, time: 1000});
                        $(obj).parent('li').parent('ul').parent('div').parent('td').parent('tr').remove();
                    } else if (data.status == 2) {
                        layer.msg('' + data.message + '', {icon: 1, time: 1000});
                    }
                }
            });
        });
    }

    function view(obj, content) {
        alert(content);
    };
</script>

</body>
</html>
